package com.test.utils;

import io.appium.java_client.android.AndroidDriver;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ScreenShotUtil {

    public static void getPayScreenShot(AndroidDriver driver, String applicantIdInput, String applicantNameInput){

        Date date = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");

        File screen = driver.getScreenshotAs(OutputType.FILE);
        String fileName="d:\\screenShot\\"+applicantIdInput+applicantNameInput+formatter.format(date)+".png";
        System.out.println("截图文件路径:"+fileName);
        File screenFile = new File(fileName);
        try {
            FileUtils.copyFile(screen,screenFile);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
